package com.guashu.springbootasynchronous.async.asyncAnnotation;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Service
public class AsyncService {

    @Async("taskExecutor1")
    public void asyncMethodWithConfiguredExecutor() throws InterruptedException {
        Thread.sleep(6000);
        // 异步执行的代码
        System.out.println("异步方法执行完毕!"
                + Thread.currentThread().getName());
    }

    @Async("taskExecutor2")
    public void anotherAsyncMethod() {
        // 另一段异步执行的代码
        System.out.println("Execute method asynchronously - "
                + Thread.currentThread().getName());
    }
}
